import Vue from 'vue'
// 引入vue-router
import VueRouter from 'vue-router'
// 引入About组件
import About from '@/pages/About.vue'
import Home from '@/pages/Home.vue'
import News from '@/pages/News.vue'
import Message from '@/pages/Message.vue'
import Detail from '@/pages/Detail.vue'

// 应用VueRouter插件
Vue.use(VueRouter)

// 创建并暴露一个路由器
export default new VueRouter({
  mode: 'history',
  // routes中配置着一组一组的路由规则
  routes: [
    {
      path: '/about',
      component: About,
      name:'guanyu'
    },
    {
      path: '/home',
      component: Home,
      name:'zhuye',
      children:[
        {
          path:'news', //注意：此处不是/news，是news
          component:News,
          name:'xinwen'
        },
        {
          path:'message',
          component:Message,
          name:'xiaoxi',
          children:[
            {
              path:'detail/:id/:title/:content?',
              component:Detail,
              name:'xiangqing',
              // 路由规则props配置————第一种写法（对象），把对象中的每一组key-value的组合传给Detail
              // props:{x:100,y:200}

              // 路由规则props配置————第二种写法（布尔值），把收到的params参数一个一个的传给Detail
              props:true
            }
          ]
        }
      ]
    }
  ]
})

